#ifndef _TASKEXECUTOR
#define _TASKEXECUTOR
#include "DataFrame.h"
#include "net_tool.h"
#include "TaskFlag.h"

// 声明模板
#define DECLARE_TASK(name) \
namespace task{ \
    class name : public ClientTaskExecutor {\
        public:\
            int clientAction(socketinf masterSockInf, const char * arg, size_t len);\
            int serverAction(socketinf slaveSockInf, unsigned long long dataLength);\
    };\
}

// 定义模板
#define MAKE_TASK_EXECUTOR(name, clientFun, serverFun) \
namespace task {    \
    int name::clientAction(socketinf masterSockInf, const char * arg, size_t len) clientFun \
    int name::serverAction(socketinf slaveSockInf, unsigned long long dataLength) serverFun\
}

#define KEEP_ALIVE 0
#define AUTO_CLOSE 1
#define CONTINUE 2

class ClientTaskExecutor {
    public:
        virtual int clientAction(socketinf masterSockInf, const char * arg = nullptr, size_t len = 0) = 0;
        virtual int serverAction(socketinf slaveSockInf, unsigned long long dataLength) = 0;
};

#endif